const Router = require('koa-router')
const updatepassword = new Router()
//！拿到前端的数据
//数据库连接池
const pg = require('pg');
let psql = new pg.Pool({
  database: 'running',
  user: 'run',
  port: 5432,
  host: '82.157.94.115',
  password: 'z12345678',
  max: 2
})

updatepassword.post('/updatepassword', async ctx => {
  // ctx.body = '首页文章推荐'
  let {username,openid,password} = ctx.request.body;
  let updateContentPostgresql = `update login set username = '${username}', password = '${password}' where openid = '${openid}'`;
  let updatepasswords = await psql.query(updateContentPostgresql);
    ctx.body = {
        updatepasswords
    };
})

module.exports = updatepassword